home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************
-
- DEMO 9
-
- Demonstrates Planar Bitmap Scaling/Clipping Functions
-
- John Slagel
- **************************************************************************/
-
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- #include <ctype.h>
- #include <alloc.h>
- #include <dos.h>
- #include "xlib.h"
- #include "xpbitmap.h"
- #include "xpbmclip.h"
- #include "xrect.h"
- #include "xbmtools.h"
- #include "xline.h"
- #include "xtext.h"
- /* Macro to make pointer parameters model independent */
- #define FARPTR(x) (MK_FP(FP_SEG(x),FP_OFF(x)))
-
- int i,j;
-
- char turtle[] = {
- 20,30,
- /* | . | . | . | . */
- 8,14, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 8, 2,14, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 8, 2, 2, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 8, 0, 2,14, 0, 0,14,14,14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 8, 0, 2, 5, 0, 4, 4, 4, 4,14,14, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 8, 0, 2, 2, 4, 4, 0, 4, 4, 0, 4,14, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 2, 4, 4, 4, 0, 4, 4, 0, 4, 4,14, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 2, 4, 4, 4, 0, 0, 0, 0, 4, 4,14, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 4, 0, 4, 4, 4, 0, 0, 0, 4, 0, 0, 2, 2, 0, 0, 0,
- 0, 0, 0, 4, 0, 4, 4, 4, 0, 4, 4, 4, 0,14, 0, 0, 2, 2, 0, 0,
- 0, 0, 0, 4, 4, 0, 0, 0, 4, 4, 0, 4, 0, 4, 2, 2, 2, 2, 0, 0,
- 0, 0, 0, 4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, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
-
-
- extern void x_scale_bm(int destx,int desty, int destwidth, int destheight, int scrnoffs, char far * data );
-
- char far *vbm;
-
- void error(char * string){
- x_text_mode();
- printf("%s\n",string);
- exit(0);
- }
-
- void main(){
- int i,j,k,handle,size,comp_size;
- char far *bm;
-
- x_text_mode(); /* make sure VGA is in color mode, if possible */
- x_set_mode(X_MODE_360x200,500); /* actually is set to 496 */
- //x_set_mode(X_MODE_320x200,320);
- ;NonVisual_Offs=16384;
-
- x_text_init();
- x_set_font(FONT_8x15);
- x_bgprintf(0,0,0,14,0," This is a demo of bitmap scaling/clipping.");
-
- bm=FARPTR(turtle);
-
- x_set_cliprect(4,5,50,150);
-
- x_line(0,TopClip-1,320,TopClip-1,23,0);
- x_line(0,BottomClip+1,320,BottomClip+1,23,0);
- x_line((LeftClip<<2)-1,0,(LeftClip<<2)-1,200,23,0);
- x_line((RightClip<<2)+4,0,(RightClip<<2)+4,200,23,0);
-
- getch();
- // Draw bm at (0,0) 160 pixels wide, 100 pixels tall.
- x_scale_bm(0,0,160,100,0,bm);
- getch();
-
- x_text_mode();
- printf("%d %d %d %d\n",LeftClip,TopClip,RightClip,BottomClip);
-
- }
-